package com.newsmanagement.controller.frontdesk;

import com.newsmanagement.common.Constants;
import com.newsmanagement.entity.ReturnedMessages;
import com.newsmanagement.service.INewsCategoryService;
import com.newsmanagement.service.ISocialDevelopmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author xbr
 * 2017.12.04 11:24
 * 后台系统 社会动态管理
 */
@Controller
@RequestMapping("frontDevelopment")
public class SocialDevelopmentFrontController {

    @Autowired
    private ISocialDevelopmentService socialDevelopmentService;

    /**
     * 发布动态（即保存动态，发布标记为发布）
     * @param eumId 操作的用户id
     * @param developmentTitle 动态标题
     * @param developmentTxt 动态内容
     * @return
     * http://localhost:8080/frontDevelopment/releaseDevelopment?eumId=1&developmentTitle=ti11111&developmentTxt=txt111111
     */
    @RequestMapping("releaseDevelopment")
    @ResponseBody
    public ReturnedMessages releaseDevelopment(
            @RequestParam(value = "eumId") Integer eumId ,
            @RequestParam(value = "developmentTitle") String developmentTitle ,
            @RequestParam(value = "developmentTxt") String developmentTxt
    ){

        return socialDevelopmentService.releaseDevelopment(eumId ,developmentTitle ,developmentTxt);
    }

    /**
     * 分页查询动态
     * @param jumpPage 跳转页面
     * @param showSize 每页显示的数据条数
     * @return ReturnedMessages
     * http://localhost:8080/frontDevelopment/list?jumpPage=1&showSize=2
     */
    @RequestMapping("list")
    @ResponseBody
    public ReturnedMessages developmentList(
            @RequestParam(value = "jumpPage") Integer jumpPage ,
            @RequestParam(value = "showSize") Integer showSize
    ){

        return socialDevelopmentService.developmentList(jumpPage ,showSize);
    }


    /**
     * 对动态点赞
     * @param eumId 点赞用户id
     * @param developmentId 被点赞动态id
     * @return ReturnedMessages
     * http://localhost:8080/frontDevelopment/like?eumId=1&developmentId=3
     */
    @RequestMapping("like")
    @ResponseBody
    public ReturnedMessages likeDevelopment(
            @RequestParam(value = "eumId") Integer eumId ,
            @RequestParam(value = "developmentId") Integer developmentId
    ){

        return socialDevelopmentService.likeDevelopment(eumId , developmentId);
    }

}
